using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SoftwareMonkeys.LiveShift.Business;

namespace SoftwareMonkeys.LiveShift.Entities
{
    public class ShiftResult : IShiftResult
    {
        private IBehavior behavior;
        /// <summary>
        /// Gets/sets the behavior that generated the result.
        /// </summary>
        public IBehavior Behavior
        {
            get { return behavior; }
            set { behavior = value; }
        }

        private IShiftableEntity[] entities;
        /// <summary>
        /// Gets/sets the affected entities (not just the one that caused the result).
        /// </summary>
        public IShiftableEntity[] Entities
        {
            get
            {
                if (entities == null)
                    entities = new IShiftableEntity[] { };
                return entities;
            }
            set { entities = value; }
        }

        private IShiftResult[] innerResults;
        public IShiftResult[] InnerResults
        {
            get {
                if (innerResults == null)
                    innerResults = new ShiftResult[] { };
                return innerResults; }
            set { innerResults = value; }
        }

        /// <summary>
        /// Adds the provided result to the inner results.
        /// </summary>
        /// <param name="result"></param>
        public void AddResult(IShiftResult result)
        {
            List<IShiftResult> results = new List<IShiftResult>(InnerResults);
            results.Add(result);
            InnerResults = results.ToArray();
        }
    }
}
